package com.woohua.demo.controller;

import com.woohua.demo.domain.PrescriptionVO;
import com.woohua.demo.domain.UserInfoRegister;
import com.woohua.demo.listener.UserService;
import com.woohua.demo.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wooHua
 * @date 2022/6/17 9:51
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private DemoService demoService;
    @Autowired
    private UserService userService;

    @GetMapping("/vo")
    public PrescriptionVO getPrescriptionVO() {
        PrescriptionVO prescriptionVO = new PrescriptionVO();
        prescriptionVO.setId(1L);
        prescriptionVO.setSingDoctorName("克里斯");
        System.out.println("CommonController.hello");
        return prescriptionVO;
    }

    @GetMapping("/hello")
    public String hello() {
        return demoService.hello();
    }

    @PostMapping("/register")
    public String register(@RequestBody UserInfoRegister userInfo) {
        System.out.println("执行注册方法");
        userService.register(userInfo.getUsername());
        return "success";
    }

}
